import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
// import Certificate from '../views/certificate/Certificate.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    //主入口文件，要求必须要有'/'的入口文件
    //重定向到path定义的/login，我们也能选择其他的页面
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('../views/Login.vue')
    },
    {
      path: '/register',
      name: 'Register',
      component: () => import('../views/register.vue')
    },
    {
      path: '/main',
      name: 'Main',
      component: () => import('../views/Main.vue')
    },
    {
      path: '/exam',
      name: 'Examination',
      component: () => import('../views/Examination.vue'),
      meta: { requiresAuth: true, title: '考试管理' }
    },
    {
      path: '/exer',
      name: 'Exer',
      component: () => import('../views/Exercise.vue')
    },
    {
      path: '/person',
      name: 'Person',
      component: () => import('../views/Person.vue')
    },
    {
      path: '/ex/create-exam',
      name: 'CreateExam',
      component: () => import('../views/ex/CreateExam.vue')
    },
    {
      path: '/ex/text-socre',
      name: 'TextScore',
      component: () => import('../views/ex/TextScore.vue')
    },
    {
      path: '/ex/miss-exam',
      name: 'MissExam',
      component: () => import('../views/ex/MissExam.vue')
    },
    {
      path: '/ex/feedback',
      name: 'Feedback',
      component: () => import('../views/ex/Feedback.vue')
    },
    {
      path: '/ex/mark-exam',
      name: 'MarkExam',
      component: () => import('../views/ex/MarkExam.vue')
    },
    {
      path: '/student-manage',
      name: 'StudentManage',
      component: () => import('../views/ex/StudentManage.vue')
    },
    {
      path: '/question-bank',
      name: 'QuestionBank',
      component: () => import('../views/question/QuestionBank.vue')
    },
    {
      path: '/exam/detail/:id',
      name: 'ExamDetail',
      component: () => import('@/views/ExamDetail.vue'),
      meta: { requiresAuth: true }
    },
    {
      path: '/exam/edit/:id',
      name: 'EditExam',
      component: () => import('@/views/EditExam.vue'),
      meta: { requiresAuth: true }
    },
    // 学生考试相关路由
    {
      path: '/student',
      component: () => import('@/views/student/Layout.vue'),
      children: [
        {
          path: 'exam-list',
          name: 'StudentExamList',
          component: () => import('@/views/student/ExamList.vue'),
          meta: { title: '考试列表' }
        },
        {
          path: 'exam-detail/:id',
          name: 'StudentExamDetail',
          component: () => import('@/views/student/ExamDetail.vue'),
          meta: { title: '考试详情' }
        },
        {
          path: 'exam-paper/:id',
          name: 'StudentExamPaper',
          component: () => import('@/views/student/ExamPaper.vue'),
          meta: { title: '考试答题' }
        },
        {
          path: 'score-inquiry',
          name: 'ScoreInquiry',
          component: () => import('@/views/student/ScoreInquiry.vue'),
          meta: {
            title: '成绩查询',
            requireAuth: true
          }
        },
        {
          path: 'mistakes',
          name: 'Mistakes',
          component: () => import('@/views/student/Mistakes.vue'),
          meta: {
            title: '错题本',
            requireAuth: true
          }
        },
        {
          path: 'certificates',
          name: 'StudentCertificates',
          component: () => import('@/views/student/Certificates.vue'),
          meta: {
            title: '我的证书',
            requireAuth: true
          }
        },
        {
          path: 'profile',
          name: 'StudentProfile',
          component: () => import('@/views/student/Profile.vue'),
          meta: {
            title: '个人中心',
            requireAuth: true
          }
        },
        {
          path: 'exam',
          name: 'StudentExam',
          component: () => import('@/views/student/Exam.vue'),
          meta: { title: '考试答题' }
        }
      ]
    },
    {
      path: '/certificate',
      name: 'certificate',
      component: () => import('../views/certificate/CertificateList.vue'),
      meta: { requiresAuth: true }
    },
    {
      path: '/certificate/template',
      name: 'certificateTemplate',
      component: () => import('../views/certificate/CertificateTemplate.vue'),
      meta: { requiresAuth: true }
    },
    {
      path: '/certificate/list',
      name: 'CertificateList',
      component: () => import('../views/certificate/CertificateList.vue'),
      meta: { requiresAuth: true }
    },
    {
      path: '/certificate/issuance',
      name: 'CertificateIssuance',
      component: () => import('../views/certificate/CertificateIssuance.vue'),
      meta: { requiresAuth: true }
    }
  ],
})

export default router
